//
//  CommentHeaderView.m
//  觅影
//
//  Created by lanou on 16/4/8.
//  Copyright © 2016年  陶虹. All rights reserved.
//

#import "CommentHeaderView.h"
@interface CommentHeaderView ()
@property(nonatomic, strong)UIImageView *picImageView;
@property(nonatomic, strong)UIImageView *headerImageView;
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *nameLabel;
@property(nonatomic, strong)UILabel *numberLabel;

@end


@implementation CommentHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        self.picImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 72, 100)];
        [self.contentView addSubview:self.picImageView];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 0, KWIDTH - 120, 60)];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.font = [UIFont systemFontOfSize:16];
        self.titleLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:self.titleLabel];
        
        self.headerImageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 75, 30, 30)];
        self.headerImageView.layer.cornerRadius = 15;
        [self.contentView addSubview:self.headerImageView];
        
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 85, 150, 20)];
        self.nameLabel.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:self.nameLabel];
        
        self.numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(KWIDTH - 50, 85, 50, 20)];
        self.numberLabel.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:self.numberLabel];
        
    }
    return self;
    
}

- (void)setModel:(HeaderModel *)model
{
    _model = model;
    
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.poster]];
    [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.header]];
    self.nameLabel.text = model.username;
    self.numberLabel.text = [NSString stringWithFormat:@"%ld回复",[model.reply_num integerValue]];
    self.titleLabel.text = model.title;
    
    if ([model.poster isEqualToString:@""]) {
        self.titleLabel.frame = CGRectMake(50, 15, KWIDTH - 100, 60);
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.headerImageView.frame = CGRectMake(10, 75, 30, 30);
        self.picImageView.hidden = YES;
        self.nameLabel.frame = CGRectMake(45, 85, 150, 20);

    }
    
}





@end
